import Vue from 'vue'
import Router from 'vue-router'
import {
  Layout
} from "../layout"; // 页面整体布局

Vue.use(Router)
const whiteList = [
  '/'
];
// 不需要权限的路由
export const constantRouterMap = [{
    path: '/login',
    name: 'login',
    component: () => import('@/page/login'),
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: '/gameManage/gameList',
    hidden: true
  }
];
//注册路由
export default new Router({
  mode: 'history', //后端支持可开
  routes: constantRouterMap
});

// 异步路由（需要权限的路由）
export const asyncRouterMap = [{
    path: '/gameManage',
    name: "gameManage",
    meta: {
      title: "游戏管理",
      icon: "el-icon-monitor"
    },
    component: Layout,
    redirect: '/gameList',
    children: [{
      path: "gameList",
      name: "gameList",
      meta: {
        title: '游戏列表',
        routerType: 'leftmenu',
        roles: ['admin', "editor"],
        icon: '',
      },
      // component: () => import('@/page/gameManage/gameList'),
      component: resolve => require(['@/page/gameManage/gameList'], resolve)
    }]

  },
  {
    path: '/openService',
    name: "openService",
    meta: {
      title: "开服管理",
      icon: "el-icon-date"
    },
    component: Layout,
    redirect: '/serviceList',
    children: [{
      path: "serviceList",
      name: "serviceList",
      meta: {
        title: '开服列表',
        routerType: 'leftmenu',
        roles: ['admin', "editor"],
        icon: '',
      },
      component: resolve => require(['@/page/openService/serviceList'], resolve)
    }]

  },
  {
    path: '/activityManage',
    name: "activityManage",
    meta: {
      title: "优惠券管理",
      icon: "el-icon-s-order"
    },
    component: Layout,
    redirect: '/activityList',
    children: [{
      path: "activityList",
      name: "activityList",
      meta: {
        title: '优惠券活动',
        routerType: 'leftmenu',
        roles: ['admin', "editor"],
        icon: '',
      },
      component: resolve => require(['@/page/activityManage/activityList'], resolve)

    }]

  },
  {
    path: '/giftManage',
    name: "giftManage",
    meta: {
      title: "礼包管理",
      icon: "el-icon-s-goods"
    },
    component: Layout,
    redirect: '/giftList',
    children: [{
        path: "giftList",
        name: "giftList",
        meta: {
          title: '礼包列表',
          routerType: 'leftmenu',
          roles: ['admin', "editor"],
          icon: '',
        },
        component: resolve => require(['@/page/giftManage/giftList'], resolve)
      },
      {
        path: "travelGiftList",
        name: "travelGiftList",
        meta: {
          title: '转游礼包列表',
          routerType: 'leftmenu',
          roles: ['admin', "editor"],
          icon: '',
        },
        component: resolve => require(['@/page/giftManage/travelGiftList'], resolve)
      }
    ]

  },
  {
    path: '/activityInfo',
    name: "activityInfo",
    meta: {
      title: "官方动态",
      icon: "el-icon-user"
    },
    component: Layout,
    redirect: '/activityInfoList',
    children: [{
        path: "activityInfoList",
        name: "activityInfoList",
        meta: {
          title: '资讯攻略',
          routerType: 'leftmenu',
          roles: ['admin', "editor"],
          icon: '',
        },
        component: resolve => require(['@/page/activityInfo/activityInfoList'], resolve)
      },

    ]

  },
  {
    path: '/rebateAudit',
    name: 'rebateAudit',
    meta: {
      title: '返利审核',
      icon: 'el-icon-document',
      roles: ['admin', 'editor']
    },
    component: Layout,
    children: [{
        path: 'extend',
        name: 'extend',
        meta: {
          title: '待发放',
          routerType: 'leftmenu',
          roles: ['admin']
        },
        component: resolve => require(['@/page/rebateAudit/extend'], resolve)
      },
      {
        path: 'audited',
        name: 'audited',
        meta: {
          title: '待审核',
          routerType: 'leftmenu'
        },
        component: resolve => require(['@/page/rebateAudit/audited'], resolve)
      },
      {
        path: 'checked',
        name: 'checked',
        meta: {
          title: '已通过',
          routerType: 'leftmenu'
        },
        component: resolve => require(['@/page/rebateAudit/checked'], resolve)
      },
      {
        path: 'reject',
        name: 'reject',
        meta: {
          title: '驳回',
          routerType: 'leftmenu'
        },
        component: resolve => require(['@/page/rebateAudit/reject'], resolve)
      },
      {
        path: 'commAudit',
        name: 'commAudit',
        meta: {
          title: '备注审核',
          routerType: 'leftmenu',
          roles: ['admin']
        },
        component: resolve => require(['@/page/rebateAudit/commAudit'], resolve)
      }
    ]
  },
  {
    path: '/dataCenter',
    name: "dataCenter",
    meta: {
      title: "数据中心",
      icon: "el-icon-s-data"
    },
    component: Layout,
    redirect: '/couponOrder',
    children: [{
      path: "couponOrder",
      name: "couponOrder",
      meta: {
        title: '订单数据',
        routerType: 'leftmenu',
        roles: ['admin', "editor"],
        icon: '',
      },
      component: resolve => require(['@/page/dataCenter/couponOrder'], resolve)

    }]

  },
  {
    path: '/eventManage',
    name: 'eventManage',
    meta: {
      title: '活动管理',
      icon: 'el-icon-star-off',
      roles: ['admin', 'editor']
    },
    component: Layout,
    children: [{
        path: 'eventList',
        name: 'eventList',
        meta: {
          title: '活动列表',
          routerType: 'leftmenu',
          roles: ['admin', 'editor']
        },
        component: resolve => require(['@/page/eventManage/eventList'], resolve)
      },
      {
        path: 'applyAudit',
        name: 'applyAudit',
        meta: {
          title: '活动申请',
          routerType: 'leftmenu',
          roles: ['admin', 'editor']
        },
        component: resolve => require(['@/page/eventManage/applyAudit'], resolve)
      },
      {
        path: 'remarkReview',
        name: 'remarkReview',
        meta: {
          title: '备注审核',
          routerType: 'leftmenu',
          roles: ['admin']
        },
        component: resolve => require(['@/page/eventManage/remarkReview'], resolve)
      }

    ]
  },
]
